package com.sc.nft.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.entity.UserEcologyReforgeRecords;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sc.nft.entity.vo.ecology.AdminEcologyReforgeUserRecordsVO;
import com.sc.nft.entity.vo.ecology.ExpendEcologyReforgeRecordsVO;
import com.sc.nft.entity.vo.ecology.ExpendEcologyReforgeRecordsVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 生态-重铸-用户记录表(sc_user_ecology_reforge_records)数据Mapper
 *
 * @author Sun
 * @since 2024-06-15 11:02:57
 * @description 由 Mybatisplus Code Generator 创建
*/
@Mapper
public interface UserEcologyReforgeRecordsMapper extends BaseMapper<UserEcologyReforgeRecords> {

    /**
     * 铸造记录
     * @param page
     * @param userId
     * @return
     */
    Page<ExpendEcologyReforgeRecordsVO> expendRecords(Page page, @Param("userId") Long userId);

    /**
     * 铸造总消耗
     * @return
     */
    @Select("select ifnull(sum(expend_count),0) from sc_user_ecology_reforge_records where expend_type = 1 and is_delete = 0 and create_time < CURDATE( )")
    BigDecimal getSumEcologyHatchReforgeTotalFuelConsumed();

    /**
     * 昨日铸造总消耗
     * @return
     */
    @Select("select ifnull(sum(expend_count),0) from sc_user_ecology_reforge_records where expend_type = 1 and is_delete = 0 and DATEDIFF(create_time,NOW())=-1")
    BigDecimal getYesterDaySumEcologyPoints();

    /**
     * 获取铸造燃料消耗
     * @param startTime
     * @param endTime
     * @return
     */
    BigDecimal getFoundryFuelConsumptionByStartTimeAndEndTime(@Param("startTime") Date startTime, @Param("endTime") Date endTime);

    /**
     * 获取用户记录
     * @param page
     * @param collectionId
     * @param userId
     * @param startTime
     * @param endTime
     * @return
     */
    Page<AdminEcologyReforgeUserRecordsVO> getPageUserRecordsRecords(Page page, @Param("collectionId") Long collectionId, @Param("userId") Long userId, @Param("startTime") String startTime, @Param("endTime")String endTime);

    /**
     *  用户熔炼记录
     * @param collectionId
     * @param userId
     * @param startTime
     * @param endTime
     * @return
     */
    List<AdminEcologyReforgeUserRecordsVO> getPageUserRecordsExport(@Param("collectionId")Long collectionId, @Param("userId")Long userId, @Param("startTime")String startTime, @Param("endTime")String endTime);

    /**
     * 获取支出明细
     * @param userId
     * @param recordsId
     * @return
     */
    List<ExpendEcologyReforgeRecordsVO> expendRecordsDetails(@Param("userId") Long userId,@Param("recordsId") Long recordsId);
}
